<template>
	<view class="merchantList">
		<view class="search">
			<u-search placeholder="请输入商家名称" v-model="name" @custom="search"></u-search>
		</view>
		<view class="list">
			<view class="listBox" v-if="list.length">
				<view class="item" v-for="(item , index) in list" :key="index">
					商家名称：<text class="itemName">{{item}}</text>
				</view>
			</view>
			<view v-else class="empty-tip">暂无商家数据</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				allList: [],
				list: [],
				name: ''
			}
		},
		onLoad() {
			this.allList = uni.getStorageSync('couponMerchant') || [];
			this.list = this.allList;
			console.log("list =>", this.list);
		},
		methods: {
			search(value) {
				const keyword = value.trim();
				if (!keyword) {
					this.list = this.allList;
					return;
				}
				this.list = this.allList.filter(item => item.includes(keyword));
			}
		}

	}
</script>

<style lang="less">
	.merchantList {
		width: 100%;
		min-height: 100vh;
		background-color: #eee;

		.search {
			width: 100%;
			padding: 30rpx;
			background-color: #fff;

		}

		.list {
			width: 100%;
			padding: 30rpx;
			box-sizing: border-box;

			.listBox {
				width: 100%;
				background-color: #fff;
				padding: 30rpx;
				box-sizing: border-box;
				border-radius: 20rpx;
				.item{
					padding: 20rpx 0;
					border-bottom: 2rpx solid #eee;
				}
			}
		}

		.empty-tip {
			width: 100%;
			text-align: center;
			color: #999;
			padding: 60rpx 0;
			font-size: 28rpx;
		}
	}
</style>